﻿package core {
	import com.greensock.TweenLite;
	
	import core.manager.AnimationManager;
	import core.manager.SpriteSheetManager;
	import core.manager.XMLManager;
	
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;

	[SWF(width=960,height=560)]
    public class Main extends Sprite {

        public var game:Game;

        public function Main(){			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.frameRate = 30;
			stage.stageFocusRect = false;
			XMLManager.instance.load();
			AnimationManager.instance.start();
			SpriteSheetManager.instance.addEventListener(Event.COMPLETE,onComplete);
			SWFProfiler.init(this.stage,this);
        }
		
		private function onComplete(event:Event):void {
			this.stage.addEventListener(MouseEvent.CLICK,startGameHandler);
		}
		
		private function startGameHandler(event:MouseEvent):void {
			this.game = new Game();
			this.addChild(this.game);
			this.game.initGame();
			this.stage.removeEventListener(MouseEvent.CLICK,startGameHandler);
		}
		
    }
}